home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / Mesa-2.2 / util / glutskel.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-10  |  1.3 KB  |  91 lines

  1. /* glutskel.c */
  2.  
  3. /*
  4.  * A skeleton/template GLUT program
  5.  */
  6.  
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <math.h>
  10. #include <GL/glut.h>
  11.  
  12.  
  13.  
  14. static void Idle( void )
  15. {
  16.  
  17. }
  18.  
  19.  
  20. static void Display( void )
  21. {
  22.    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
  23.  
  24.    /* draw stuff here */
  25.  
  26.    glutSwapBuffers();
  27. }
  28.  
  29.  
  30. static void Reshape( int width, int height )
  31. {
  32.    glViewport( 0, 0, width, height );
  33.    glMatrixMode( GL_PROJECTION );
  34.    glLoadIdentity();
  35.    glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 );
  36.    glMatrixMode( GL_MODELVIEW );
  37.    glLoadIdentity();
  38.    glTranslatef( 0.0, 0.0, -15.0 );
  39. }
  40.  
  41.  
  42. static void Key( unsigned char key, int x, int y )
  43. {
  44.    switch (key) {
  45.       case 27:
  46.          exit(0);
  47.          break;
  48.    }
  49.    glutPostRedisplay();
  50. }
  51.  
  52.  
  53. static void SpecialKey( int key, int x, int y )
  54. {
  55.    switch (key) {
  56.       case GLUT_KEY_UP:
  57.          break;
  58.       case GLUT_KEY_DOWN:
  59.          break;
  60.    }
  61.    glutPostRedisplay();
  62. }
  63.  
  64.  
  65. static void Init( void )
  66. {
  67.    /* setup lighting, etc */
  68. }
  69.  
  70.  
  71. int main( int argc, char *argv[] )
  72. {
  73.  
  74.    glutInit( &argc, argv );
  75.    glutInitWindowSize( 400, 400 );
  76.  
  77.    glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
  78.  
  79.    glutCreateWindow( "my window" );
  80.  
  81.    Init();
  82.  
  83.    glutReshapeFunc( Reshape );
  84.    glutKeyboardFunc( Key );
  85.    glutSpecialFunc( SpecialKey );
  86.    glutDisplayFunc( Display );
  87.    glutIdleFunc( Idle );
  88.  
  89.    glutMainLoop();
  90. }
  91.